import cv2
import numpy as np
# 通过填充轮廓的方式计算面积
def cal_area(cnt):
    img = np.zeros((int(np.array(cnt).flatten().max())+1,int(np.array(cnt).flatten().max())+1),np.uint8)
    cv2.drawContours(img, contours = [np.int0(cnt)], contourIdx = 0, color = 1, thickness=-1)
    area = img.sum()
    return area

